<?php
  include_once('header.php');

  limits($conn, '图书管理');
?>
    <div class="layui-body" style="padding: 15px;">
    <!-- 图书管理 - 新增图书 -->
      <!-- 内容主体区域 -->
      <div>图书管理</div>
      <div class="layui-tab layui-tab-brief">
        <ul class="layui-tab-title">
          <li><a href="book_list.php">图书列表</a></li>
          <li><a class="layui-this">新增图书</a></li>
        </ul>
      </div>

      <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">
          <div class="layui-row">
            <div class="layui-col-md8">
              <form class="layui-form" method="post" action="book_save.php">
                <div class="layui-form-item">
                  <label class="layui-form-label">图书名称 *</label>
                  <div class="layui-input-block">
                    <input type="text" name="book_name" required lay-verify="required" class="layui-input" />
                  </div>
                </div>

                <div class="layui-form-item">
                  <label class="layui-form-label">图书分类 *</label>
                  <div class="layui-input-block">
                    <select name="book_category" lay-verify="required" >
                      <option value="">请选择类型</option>
                      <?php
                        $sql = "select * from category order by id";
                        $result = mysqli_query($conn, $sql);
                        if($result) {
                          while($rows = mysqli_fetch_assoc($result)) {
                            echo "<option value=".$rows['category_name'].">".$rows['category_name']."</option>";
                          }
                        }
                      ?>
                    </select>
                  </div>
                </div>

                <div class="layui-form-item">
                  <label class="layui-form-label">图书位置 *</label>
                  <div class="layui-input-block">
                    <select name="book_position" lay-verify="required" >
                      <option value="">请选择类型</option>
                      <?php
                        $sql = "select * from position order by id";
                        $result = mysqli_query($conn, $sql);
                        if($result) {
                          while($rows = mysqli_fetch_assoc($result)) {
                            echo "<option value=".$rows['position_name'].">".$rows['position_name']."</option>";
                          }
                        }
                      ?>
                    </select>
                  </div>
                </div>

                <div class="layui-form-item">
                  <label class="layui-form-label">图书数量 *</label>
                  <div class="layui-input-block">
                    <input type="text" name="book_count" required lay-verify="required" class="layui-input" />
                  </div>
                </div>

                <div class="layui-form-item">
                  <div class="layui-input-block">
                    <input type="submit" class="layui-btn layui-btn-normal" value="提交" />
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                  </div>
                </div>
              </form>
            </div>
          </div>
        </div>
      </div>

    </div>
<?php
  include('footer.php');
?>